
<?php
	$path_one = 'admin/admin_project';
	$path_two = 'admin/admin_address_device_log';
	$filename = 'admin/admin_address_device_log';
	require_once("header.php");
	require_once("admin_comm.php");
	require_once $_site->get_handlepath('project');
	require_once $_site->get_handlepath('device');

    $did=request('did');  //记录id
    if(!$did)return false;
    $time=request('time');//间隔时间（秒）
    if($time>3600 || $time<=0)$time=1200;


    //获取记录信息
    $cinfo=	device_fun_get_record($did);
    $pid=$cinfo['pid'];
    $pinfo=project_fun_get_project_info($cinfo['pid']);


	$page=request('page',false,true,false,1);
	$pagesize=request('pagesize',false,true,false,60);
	$pagesize = is_numeric($pagesize)?$pagesize:60;
	$data['pid']=$pid;
	$data['state']=request('state',false,true,false,1);
	$data['address']=request('address',true,false,false,0);//作业点id
	$data['no']=request('no',true,false,false,0);
	$data['type']=$type=request('type',true,false,false,1);
	$data['truck']=$truck=request('truck',true,false,false,0);
	$data['dust']=$dust=request('dust',true,false,false,0);
	$data['onload']=$onload=request('onload',true,false,false,0);
	$data['dname']=$dname=request('dname');
	$data['jsno']=$jsno=request('jsno');
	$data['dkno']=$dkno=request('dkno');
	$data['fbtime']=$fbtime=request('fbtime');
	$no_title=request('no_title');



//合理时间
	$time_hl=request('time_hl',false,true,false,120);
	if($time_hl<=0 || $time_hl>86400)$time_hl=120;

	$start_time=$data['start_time']=request('start_time');
	$end_time=$data['end_time']=request('end_time');
	if(empty($start_time) && empty($end_time)){
        $ctime=$cinfo['ctime'];
	    $end_time=$data['end_time']=date("Y-m-d H:i:s",$ctime+90);
	    $start_time=$ctime-90;
        $start_time=$data['start_time']=date("Y-m-d H:i:s",$start_time);
	}






	$result = device_fun_get_checkin_list($data,$page,$pagesize);

	$hover[$data['state']]=' class="hover" ';
	$address_list = $data['pid']&&$data['address']==false?$project->get_project_address_list(array('all'=>true,'pid'=>$data['pid'])):false;//作业点列表
	if($data['address']){
		$address_info = project_fun_get_project_address_info($data['address']);
	}
	$truckType=array('a'=>'A 型','b'=>'B 型','c'=>'C 型');
	$dustType=array('1'=>'Ⅰ类','2'=>'Ⅱ类','3'=>'Ⅲ 类');
	$onloadType=array(1=>"空车",2=>"重车");
	$stateType=array(1=>"有效",0=>"无效");

	function time2second($seconds){
		$seconds = (int)$seconds;
		if( $seconds<86400 ){//如果不到一天
			$format_time = gmstrftime('%H 时 %M 分 %S 秒 ', $seconds);
		}else{
			$time = explode(' ', gmstrftime('%j %H %M %S', $seconds));
			$format_time = ($time[0]-1).'天'.$time[1].'时'.$time[2].'分'.$time[3].'秒';
		}
		return $format_time;
	}
?>
<link rel="stylesheet" type="text/css" href="/static/skin/green/css/list.css">
<script type="text/javascript" charset="utf-8">

	loader.file({
		plugin:['validform/main','dialog/main','my97/wdatepicker']
	})


	window.onload=function (){
		get_address_list('<?php echo $data['pid'];?>','<?php echo $data['address'];?>');
	}


    function clearfbtime(){
        $("#fbtime").val('');
        dialog.close('choise_fbtim');
    }

    function choosefbtime(datestr){
        $("#fbtime").val(datestr);
        dialog.close('choise_fbtim');
    }

	function change(info){
		var onload = '重车'==info.onload?'<span class="red">重车</span>':'<span class="green">空车</span>';
		var infos= $("#no_"+info.id).find("p:eq(0)").html().replace(/<span class="(red|green)">(空车|重车)<\/span>/,onload);
		$("#no_"+info.id).find("p:eq(0)").html(infos);
        $("#no_"+info.id).find("p:eq(3)").html("<strong>车型</strong>  "+info.truck+"   <strong>土石</strong>  "+info.dust);
	}
</script>
<style>
.goodimg{width:180px;background: #efefef none repeat scroll 0 0;border: 1px solid #aad381;}
.goodwarn{width:180px;background: #ff0 none repeat scroll 0 0;border: 1px solid #ff0000;}
.table li{float:left;margin-right: 10px;margin-top: 10px;text-align: center;}
.table img{max-width:160px;height:120px;margin:5px;}
.table .text{text-align:left;margin-left:10px;}
.table .operation{background:#aad381}
</style>
</head>
<body>
		<div class="main">

			<div class="sos_box">
				<form action="/admin/admin_address_device_log_judge" id="search" method='get'>
					<input type="hidden" name="type" value="1">
                    <input type="hidden" name="did" value="<?php echo $did; ?>">
					<span>项目名称：</span>
					<?php echo $pinfo['title']; ?>
					<div style="clear: both;width:100%;*height:0px;margin:5px 0;"></div>
                    <span>车牌号：</span>
                    <input type="text"  name="dname" value="<?php echo $data['dname'] ;?>">
					<span>登记时间：</span>
					<input style="width: 140px" class='date_icon' type="text" id="d4311" name="start_time" value="<?php echo $start_time ;?>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'#F{$dp.$D(\'d4312\')||\'<?php echo date('Y-m-d');?>\'}',readOnly:true})"> -
					<input style="width: 140px" type="text" id="d4312" name="end_time" value="<?php echo $end_time ;?>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'d4311\')}',maxDate:'<?php echo date('Y-m-d');?>',readOnly:true})">
					<input class="button1" type="submit" value="搜索">
					<div style="clear: both;width:100%;*height:0px;margin:5px 0;"></div>
					<div style="clear: both;width:100%;*height:0px;margin:5px 0;"></div>
				</form>
			</div>
			<table cellpadding="0" cellspacing="1" border="0" class="table">
				<?php
					if($result['rows']){
                 ?>
                 <tr><td>
                 <?php
				   foreach ($result['rows'] as $k=>$v){
                       $length=0;
                       if($result['rows'][$k+1]['ctime'])
                       $length=$v['ctime']-$result['rows'][$k+1]['ctime'];
                       //$_class=($length>900||$length<90)?'goodwarn':'goodimg';
                       $_class=($length<$time_hl && $length>0)?'goodwarn':'goodimg';
				 ?>
			     <li id="no_<?php echo $v['id'];?>">
                     <div class="<?php echo $_class;?>">
					 <a href="<?php echo $v['img'];?>" title="点击查看大图" target="_blank">
                     <img src='<?php $img=1==$v['delimg']?'/static/images/imgdel.jpg':$v['img'];echo $img ;?>' width="156px" height="80px">
					 </a>
                     <p class="text">
                        <?php echo "<span class='".((1==$v['onload'])?'green':'red')."'>登记</span>&nbsp;&nbsp;".date("y-m-d H:i",$v['ctime']) ;?>
                     </p>
                     <p class="text"><strong><?php echo $v['dno'] ;?></strong></p>
                     <p class="text"><strong>车牌号</strong>  <?php echo $v['dname'] ;?></p>
                     <p class="text">
                       <strong>车型</strong>  <?php echo $truckType[$v['truck']] ;?>
                       <strong>土石</strong>  <?php echo $dustType[$v['dust']] ;?>
                     </p>
                     <p class="text"><strong>机手编号</strong>  <?php echo $v['jsno'] ;?></p>
                     <p class="text"><strong>地块编号</strong>  <?php echo $v['dkno'] ;?></p>
                     <p class="text"><strong>登记间隔</strong> <span class="red"><?php echo time2second($length);?></span></p>
                     <p class="operation">
                     <?php if($open && $cookie['group']!=12){?>
                       <a href="javascript:;" onclick="editinfo(<?php echo $v['id'];?>);" >编辑</a>
                       &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="nouse(<?php echo $v['id'];?>);" title="点击设置记录无效">无效</a>
                       <?php } ?>
                     </p>
                     </div>
                 </li>
				<?php
						}
				?>
						</td></tr>
						<?php
					}else{
						?>
						<tr>
							<td colspan="10">暂无数据！</td>
						</tr>
						<?php
					}
				?>
				<tr>
					<td colspan="10">
						<div class="list_more">
							记录总数：<?php echo $result['row_count']?$result['row_count']:0 ;?>
							<?php
								echo page_method($result['row_count'], $page, $result['page_count'], 10, '?'.preg_replace('/(&page=\d*)/','',$_SERVER['QUERY_STRING']), false);
							?>
						</div>
					</td>
				</tr>
			</table>
		</div>
	</div>
</body>
</html>


